package org.docmanagement.forms;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;
import org.docmanagement.data.Category;
import org.docmanagement.data.Keyword;

/**
 * @author Manuel EVENO
 */
public class ElementForm extends IdForm
{
	private static final long serialVersionUID = 1L;

	protected String 		title = null;
	protected String 		description = null;
	protected char			type = 0;
	protected String		filepath = null;
	protected String		url = null;
	protected boolean		addnewkeyword = false;
	protected String		newkeyword = null;
	protected Integer[]		keywordIds = new Integer[0];
	protected Integer[] 	categoryIds = new Integer[0];
	protected List<Category>			categories = null;
	protected List<Keyword>			keywords = null;
	protected Integer		mainCategoryId = null;
	protected CategoryForm	mainCategory = null;
	/**
	 * Constructor for Document.
	 */
	public ElementForm()
	{
		super();
	}
	/**
	 * Returns the title.
	 * @return String
	 */
	public String getTitle()
	{
		return (title != null) ? title : "";
	}
	/**
	 * Returns the description.
	 * @return String
	 */
	public String getDescription()
	{
		return (description != null) ? description : "";
	}
	/**
	 * Returns the extension of the file
	 * @return String
	 */
	public String getIconType()
	{
		return "";
	}
	/**
	 * @return
	 */
	public char getType()
	{
	    return type;
	}
	/**
	 * @return
	 */
	public Integer[] getKeywordIds()
	{
		return keywordIds;
	}
	/**
	 * Sets the description.
	 * @param description The description to set
	 */
	public void setDescription(String description)
	{
		this.description = description;
	}
	/**
	 * Sets the title.
	 * @param title The title to set
	 */
	public void setTitle(String title)
	{
		this.title = title;
	}
	/**
	 * @return
	 */
	public void setType(char type)
	{
		this.type = type;
	}
	/**
	 * Returns the categories.
	 * @return int[]
	 */
	public Integer[] getCategoryIds()
	{
		return categoryIds;
	}
	/**
	 * Sets the categories.
	 * @param categories The categories to set
	 */
	public void setCategoryIds(Integer[] pIds)
	{
		this.categoryIds = pIds;
	}
	/**
	 *
	 * @return
	 */
//	public boolean hasCategories()
//	{
//		return (categories.size() != 0);
//	}
	/**
	 * @return
	 */
    public Integer getMainCategoryId()
    {
        return mainCategoryId;
    }
    /**
     * @param maincategory
     */
    public void setMainCategoryId(Integer id)
    {
        this.mainCategoryId = id;
    }
	/**
	 * @return
	 */
    public CategoryForm getMainCategory()
    {
        return mainCategory;
    }
    /**
     * @param maincategory
     */
    public void setMainCategory(CategoryForm cat)
    {
        this.mainCategory = cat;
    }
	/**
	 * @param string
	 */
	public void setKeywordIds(Integer[] pIds)
	{
        keywordIds = pIds;
	}
	/**
	 * @return
	 */
    public boolean isAddnewkeyword()
    {
        return addnewkeyword;
    }
    /**
     * @param addnewkeyword
     */
    public void setAddnewkeyword(boolean b)
    {
        this.addnewkeyword = b;
    }
    /**
     * @return
     */
    public String getNewkeyword()
    {
        return newkeyword;
    }
    /**
     * @param newkeyword
     */
    public void setNewkeyword(String newkeyword)
    {
        this.newkeyword = newkeyword;
    }
    /**
     * @return
     */
    public String getFilepath()
    {
        return filepath;
    }
    /**
     * @param filename
     */
    public void setFilepath(String pFilepath)
    {
        this.filepath = pFilepath;
    }
    /**
     * @return
     */
    public String getUrl()
    {
        return url;
    }
    /**
     * @param url
     */
    public void setUrl(String url)
    {
        this.url = url;
    }
    /**
     * @return
     */
    public List<Category> getCategories()
    {
        return categories;
    }
    /**
     * @param
     */
    public void setCategories(List<Category> pCategories)
    {
        this.categories = pCategories;
    }
    /**
     * @return
     */
    public List<Keyword> getKeywords()
    {
        return keywords;
    }
    /**
     * @param
     */
    public void setKeywords(List<Keyword> pKeywords)
    {
        this.keywords = pKeywords;
    }
    /**
     * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
     */
    public void reset(ActionMapping mapping, HttpServletRequest request)
    {
        super.reset(mapping, request);
        title = null;
        description = null;
    	title = null;
    	description = null;
    	type = 0;
    	filepath = null;
    	url = null;
    	categoryIds = new Integer[0];
    	keywordIds = new Integer[0];
    	categories = null;
    	keywords = null;
    	addnewkeyword = false;
    	newkeyword = null;
    	mainCategoryId = null;
    	mainCategory = null;
    }
}
